﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MaterialDesignThemes.Wpf;
using 带导航.ViewModels;

namespace 带导航;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

    private readonly MainViewModel _viewModel;

    public MainWindow()
    {
        _viewModel = new MainViewModel();
        DataContext = _viewModel;

        InitializeComponent();

        MenuToggleButton.Visibility = Visibility.Collapsed;
        NavRail.Visibility = Visibility.Collapsed;
    }


    private void MenuOpen_Click(object sender, RoutedEventArgs e)
    {
        NavDrawer.IsLeftDrawerOpen = false;
        if (ActualWidth > 1000)
        {
            NavRail.Visibility = Visibility.Visible;
            MenuToggleButton.Visibility = Visibility.Visible;
        }

    }


    private void MenuToggleButton_OnClick(object sender, RoutedEventArgs e)
    {
        if (ActualWidth > 1000)
        {
            NavRail.Visibility = Visibility.Collapsed;
            MenuToggleButton.Visibility = Visibility.Collapsed;
        }

    }


    /// <summary>
    /// TreesView's SelectedItem is read-only. Hence we can't bind it. There is a way to obtain a selected item.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
    {

    }
}
